package postprocessing;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Formatter;

public class ExtractTopResults {

	public static void main(String[] args) throws IOException, InterruptedException {
		File dir = new File("/local/joofeit/RESULTSALL/results_6_sorted");
		String top10Path = "/local/joofeit/TOP10";
		BufferedWriter bw;
		File verbs = new File("/local/joofeit/BACKALL/backAll_6/Dist/");
		String path = "/local/joofeit/BACKALL/backAll_6/Dist/";
		String[] verbsFiles = verbs.list();
		BufferedReader br;
		File[] files = dir.listFiles();
		int counter;
		String line = "";
		Formatter fmt;

		for (File f : files) {
//			bw = new BufferedWriter(new FileWriter(new File(top10Path + "/"
//					+ f.getName() + "_top10.txt")));
			String dirNew = "/local/joofeit/DISTFILTERED6/" + f.getName();
			new File(dirNew).mkdir();
			counter = 0;
//			bw
//					.write("\t\t-----------"
//							+ f.getName().split("__")[0].replaceAll("_", " ")
//									.replaceFirst("results ", "")
//							+ "-----------\n\n\n");
//			fmt = new Formatter();
//			fmt.format("%-15s %-15s %-17s %-15s %n", "", "ideale",
//					"kein ideale", "hat nichts mit");
//			bw.write(fmt + "");
//			fmt = new Formatter();
//			fmt.format("%-15s %-15s %-17s %-15s %n", "", "Paraphrase ",
//					"Paraphase,", "der MWE gemein");
//			bw.write(fmt + "");
//			fmt = new Formatter();
//			fmt.format("%-15s %-15s %-17s %-15s %n", "", "",
//					"aber sinnverwandt", "");
//			bw.write(fmt + "");
			br = new BufferedReader(new FileReader(f));
			while ((line = br.readLine()) != null && (counter < 100)) {
//				System.out.println(line);
//				fmt = new Formatter();
				String[] split = line.split(" ");
//				if (split[1].equals("ausmerzen") || split[1].equals("wollen")
//						|| split[1].equals("sollen")||split[1].equals("werden"))
//					continue;
//				fmt.format("%-15s %-15s %-17s %-15s %n", split[1], "()", "()",
//						"()");
//				bw.write(fmt + "");

				System.out
						.println(split[2] + "_" + split[1] + "_6_dist_.data");

				 Runtime.getRuntime().exec(
				 "cp " +path+ split[2] + "_" + split[1] + "_6_dist_.data"+
				" " + dirNew + "/");

				counter++;
			}
			Thread.sleep(4000);
//			bw.flush();
//			bw.close();
			br.close();

		}

	}

}
